package dao

import (
	"yundian/internel/pkg/dingo"
)

func (d *OrderDao) InsertOrderCorrelation(tradeNo string) *dingo.ErrorWrap {
	//
	////查询订单信息
	//orderInfo := NewOrderDao().OrderInfoByTradeNo(tradeNo).Unwrap().(*orders.OrderModel)
	//db := global.Orm
	//var kaUserId int
	//
	////递归查询上级
	//placeModel := &placemodel.PlaceModel{}
	////查询网点是否关联分公司
	//global.Orm.Table("places").Where("id = ?", orderInfo.PlaceId).Find(placeModel)
	//
	//if placeModel.BranchUserId > 0 {
	//	kaUserId = placeModel.BranchUserId
	//}
	//
	//userList := NewUserDao().QueryParentList(orderInfo.UserId, kaUserId).Unwrap().([]*users.UserModel)
	//
	////去重用户Id
	//
	//var userIds []int
	//for _, model := range userList {
	//	userIds = append(userIds, model.ID)
	//}
	//
	//userIds = utils.RemoveRepByMap(userIds)
	//
	//for _, id := range userIds {
	//	var ordersUserRelevancy orders.OrdersUserRelevancy
	//	ordersUserRelevancy.TradeNo = tradeNo
	//	ordersUserRelevancy.UserId = id
	//	db.Table("orders_user_relevancy").Create(&ordersUserRelevancy)
	//}
	//
	//if db.Error != nil {
	//	return dingo.ErrorIf(db.Error, false)
	//}
	//return dingo.ErrorIf(db.Error, true)
	return dingo.ErrorIf(nil, true)
}
